// createRouter 用来新建路由实例，createWebHashHistory 用来配置我们内部使用 hash 模式的路由，也就是 url 上会通过 # 来区分。
import { createRouter, createWebHashHistory, RouterView } from "vue-router";

const routes = [
  {
    path: "/",
    redirect: "/product",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/login.vue"),
  },
  {
    path: "/", //这个固定，不要动
    meta: {
      title: "菜单列表",
      isNav: true, //开启导航菜单（非菜单渲染数据放在外面同级）
    },
    component: () => import("@/views/home.vue"),
    // 需要渲染到导航组件的放在一个list中
    children: [
      {
        //注意，这里是单独首页的配置，比如大屏，纯后台管理页面请修改isMenu和isIndependent相反，或者删除这个配置
        path: "/index",
        name: "index",
        meta: {
          title: "首页",
          icon: "",
          isMenu: false, //是否展示在导航侧边栏
          isIndependent: true, //是否独立页面，与上面的isMenu互斥
        },
        component: () => import("@/views/index/index.vue"),
      },
	  {
		path: "/product",
		meta: {
		  title: "设备管理",
		  icon: "",
		  isMenu: true, //是否展示在导航侧边栏
		},
		component: RouterView,
		children: [
		  {
			path: "/product",
			name: "product",
			meta: {
			  title: "产品列表",
			  icon: "index",
			  isMenu: true,
			},
			component: () => import("@/views/device/productList.vue"),
		  },
		  {
			path: "/productCustomDetail",
			name: "productCustomDetail",
			meta: {
			  title: "产品详情",
			  icon: "index",
			  isMenu: false,
			},
			component: () => import("@/views/device/productCustomDetail.vue"),
		  },
		  {
			path: "/deviceListDetail",
			name: "deviceListDetail",
			meta: {
			  title: "设备详情",
			  icon: "index",
			  isMenu: false,
			},
			component: () => import("@/views/device/deviceListDetail.vue"),
		  },
		  {
			path: "/device",
			name: "device",
			meta: {
			  title: "设备列表",
			  icon: "index",
			  isMenu: true,
			},
			component: () => import("@/views/device/deviceList.vue"),
		  },
		],
	  },
	  {
		path: "/sysSetting",
		name: "sysSetting",
		meta: {
			title: "系统配置",
			icon: "index",
			isMenu: true,
		  },
		component: () => import("@/views/sysSetting/sysSetting.vue"),
	  },
    ],
  },
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/404.vue"),
  },
  {
    path: "/:pathMatch(.*)",
    redirect: "/404",
  },
];

const router = createRouter({
  routes,
  history: createWebHashHistory(),
});

export default router;
